package com.wujie.activies.service.imp;

import com.wujie.activies.dao.ActivityTypeMapper;
import com.wujie.activies.model.ActivityType;
import com.wujie.activies.model.ActivityTypeExample;
import com.wujie.activies.service.IActivityTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by 晒太阳的鱼 on 2015/12/20.
 */
@Service("activityTypeService")
public class ActivityTypeServiceImpl implements IActivityTypeService {
    @Autowired
    private ActivityTypeMapper activityTypeMapper;


    @Override
    public List<ActivityType> getAll() {
        ActivityTypeExample ate = new ActivityTypeExample();
        return activityTypeMapper.selectByExample(ate);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return activityTypeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public ActivityType getByPrimaryKey(Integer key) {
        return activityTypeMapper.selectByPrimaryKey(key);
    }

    @Override
    public List<ActivityType> getByInstance(ActivityType ele) {
        ActivityTypeExample ate = new ActivityTypeExample();
        ate.createCriteria().andNameEqualTo(ele.getName());
        return activityTypeMapper.selectByExample(ate);
    }

    @Override
    public int updateByPrimaryKey(ActivityType ele) {
        return activityTypeMapper.updateByPrimaryKeySelective(ele);
    }

    @Override
    public int insertSelective(ActivityType ele) {
        return activityTypeMapper.insertSelective(ele);
    }



}
